package com.person.ntv.service.sys.impl;

import java.math.BigDecimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.person.common.PageParams;
import com.person.exception.ServiceException;
import com.person.ntv.dao.sys.SysCodeMapper;
import com.person.ntv.entity.sys.SysCode;
import com.person.ntv.service.base.impl.BaseServiceImpl;
import com.person.ntv.service.sys.CommonService;
import com.person.ntv.service.sys.SysCodeService;
@Service("sysCodeService")
public class SysCodeServiceImpl extends BaseServiceImpl<SysCode> implements SysCodeService{
	@Autowired
   private SysCodeMapper sysCodeMapper;
   @Autowired
   private CommonService commonService;
   @Autowired
   public void setBaseMapper(){
	   super.setBaseMapper(this.sysCodeMapper);
   }

@Override
public int deleteByPrimaryKeys(BigDecimal[] ids) {
	try{
		int result=0;
	    for(BigDecimal id:ids){
	    	result+=deleteByPrimaryKey(id);
	    }
	    return result;
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  }
}


@Override
public Page<SysCode> getCodePage(PageParams params)
		throws ServiceException {
	try{
		PageHelper.startPage(params.getPage(),params.getRows(),params.getOrderStr(null));
		return sysCodeMapper.selectPage(params.getParams());
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  } 
}

@Override
public int validateItemName(String itemName, String id,String csId) throws ServiceException {
	try{
	    return sysCodeMapper.validateItemName(itemName, id, csId);
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  } 
}

@Override
public int validateItemValue(String itemValue, String id,String csId)
		throws ServiceException {
	try{
	    return sysCodeMapper.validateItemValue(itemValue, id, csId);
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  } 
}
   
}
